<!doctype html>
<html class="no-js" lang="">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title>sup-mimi-program-server documentation</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <link rel="icon" type="image/x-icon" href="../images/favicon.ico">
	   <link rel="stylesheet" href="../styles/style.css">
        <link rel="stylesheet" href="../styles/dark.css">
        <link rel="stylesheet" href="../styles/postmark.css">
    </head>
    <body>
          <script>
               // Blocking script to avaoid flickering dark mode
               // Dark mode toggle button
               var useDark = window.matchMedia('(prefers-color-scheme: dark)');
               var darkModeState = useDark.matches;
               var $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input');
               var $darkModeToggles = document.querySelectorAll('.dark-mode-switch');
               var darkModeStateLocal = localStorage.getItem('compodoc_darkmode-state');

               function checkToggle(check) {
                    for (var i = 0; i < $darkModeToggleSwitchers.length; i++) {
                         $darkModeToggleSwitchers[i].checked = check;
                    }
               }

               function toggleDarkMode(state) {
                    if (window.localStorage) {
                         localStorage.setItem('compodoc_darkmode-state', state);
                    }

                    checkToggle(state);

                    const hasClass = document.body.classList.contains('dark');

                    if (state) {
                         for (var i = 0; i < $darkModeToggles.length; i++) {
                              $darkModeToggles[i].classList.add('dark');
                         }
                         if (!hasClass) {
                              document.body.classList.add('dark');
                         }
                    } else {
                         for (var i = 0; i < $darkModeToggles.length; i++) {
                              $darkModeToggles[i].classList.remove('dark');
                         }
                         if (hasClass) {
                              document.body.classList.remove('dark');
                         }
                    }
               }

               useDark.addEventListener('change', function (evt) {
                    toggleDarkMode(evt.matches);
               });
               if (darkModeStateLocal) {
                    darkModeState = darkModeStateLocal === 'true';
               }
               toggleDarkMode(darkModeState);

               if ($darkModeToggles.length > 0) {
                    for (var i = 0; i < $darkModeToggleSwitchers.length; i++) {
                         $darkModeToggleSwitchers[i].addEventListener('change', function (event) {
                              darkModeState = !darkModeState;
                              toggleDarkMode(darkModeState);
                         });
                    }
               }
          </script>

        <div class="navbar navbar-default navbar-fixed-top d-block d-sm-none">
            <a href="../" class="navbar-brand">sup-mimi-program-server documentation</a>
            <button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
        </div>

        <div class="xs-menu menu" id="mobile-menu">
                <div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div>            <compodoc-menu></compodoc-menu>
        </div>

        <div class="container-fluid main">
           <div class="row main">
               <div class="hidden-xs menu">
                   <compodoc-menu mode="normal"></compodoc-menu>
               </div>
               <!-- START CONTENT -->
               <div class="content injectable">
                   <div class="content-data">








<ol class="breadcrumb">
  <li class="breadcrumb-item">Injectables</li>
  <li class="breadcrumb-item" >WeappService</li>
</ol>

<ul class="nav nav-tabs" role="tablist">
        <li class="nav-item">
            <a href="#info" 
                class="nav-link"
                class="nav-link active"
                role="tab" id="info-tab" data-bs-toggle="tab" data-link="info">Info</a>
        </li>
        <li class="nav-item">
            <a href="#source" 
                class="nav-link"
                
                role="tab" id="source-tab" data-bs-toggle="tab" data-link="source">Source</a>
        </li>
</ul>

<div class="tab-content">
    <div class="tab-pane fade active in" id="info">
        <p class="comment">
            <h3>File</h3>
        </p>
        <p class="comment">
            <code>src/weapp/weapp.service.ts</code>
        </p>





            <section data-compodoc="block-index">
    <h3 id="index">Index</h3>
    <table class="table table-sm table-bordered index-table">
        <tbody>
                <tr>
                    <td class="col-md-4">
                        <h6><b>Properties</b></h6>
                    </td>
                </tr>
                <tr>
                    <td class="col-md-4">
                        <ul class="index-list">
                            <li>
                                    <span class="modifier"></span>
                                    <span class="modifier">Private</span>
                                <a href="#configService" >configService</a>
                            </li>
                        </ul>
                    </td>
                </tr>

                <tr>
                    <td class="col-md-4">
                        <h6><b>Methods</b></h6>
                    </td>
                </tr>
                <tr>
                    <td class="col-md-4">
                        <ul class="index-list">
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#createWxInfo" >createWxInfo</a>
                            </li>
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#findAll" >findAll</a>
                            </li>
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#getAccessToken" >getAccessToken</a>
                            </li>
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#getOpenId" >getOpenId</a>
                            </li>
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#getOpenIdByWx" >getOpenIdByWx</a>
                            </li>
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#getOpenIdFromDb" >getOpenIdFromDb</a>
                            </li>
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#getPhoneNumber" >getPhoneNumber</a>
                            </li>
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#getPhoneNumberByCrypto" >getPhoneNumberByCrypto</a>
                            </li>
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#removeWxInfo" >removeWxInfo</a>
                            </li>
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#sendMessage" >sendMessage</a>
                            </li>
                            <li>
                                    <span class="modifier">Async</span>
                                <a href="#updateWxInfo" >updateWxInfo</a>
                            </li>
                        </ul>
                    </td>
                </tr>





        </tbody>
    </table>
</section>

            <section data-compodoc="block-constructor">
    <h3 id="constructor">Constructor</h3>
        <table class="table table-sm table-bordered">
            <tbody>
                <tr>
                    <td class="col-md-4">
<code>constructor(weappModel: ReturnModelType<>)</code>
                    </td>
                </tr>
                        <tr>
                            <td class="col-md-4">
                                <div class="io-line">Defined in <a href="" data-line="26" class="link-to-prism">src/weapp/weapp.service.ts:26</a></div>
                            </td>
                        </tr>

                <tr>
                    <td class="col-md-4">
                            <div>
                                    <b>Parameters :</b>
                                    <table class="params">
                                        <thead>
                                            <tr>
                                                <td>Name</td>
                                                    <td>Type</td>
                                                <td>Optional</td>
                                            </tr>
                                        </thead>
                                        <tbody>
                                                <tr>
                                                        <td>weappModel</td>
                                                  
                                                        <td>
                                                                    <code>ReturnModelType&lt;&gt;</code>
                                                        </td>
                                                  
                                                    <td>
                                                            No
                                                    </td>
                                                    
                                                </tr>
                                        </tbody>
                                    </table>
                            </div>
                    </td>
                </tr>
            </tbody>
        </table>
</section>

            <section data-compodoc="block-methods">
    
    <h3 id="methods">
        Methods
    </h3>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="createWxInfo"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>createWxInfo</b></span>
                        <a href="#createWxInfo"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>createWxInfo(createDto: <a href="../classes/CreateWeappDto.html" target="_self">CreateWeappDto</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="155"
                                    class="link-to-prism">src/weapp/weapp.service.ts:155</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>createDto</td>
                                            <td>
                                                            <code><a href="../classes/CreateWeappDto.html" target="_self" >CreateWeappDto</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>unknown</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="findAll"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>findAll</b></span>
                        <a href="#findAll"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>findAll()</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="105"
                                    class="link-to-prism">src/weapp/weapp.service.ts:105</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                        <div class="io-description">
                            <b>Returns : </b>    <code>unknown</code>

                        </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getAccessToken"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>getAccessToken</b></span>
                        <a href="#getAccessToken"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>getAccessToken()</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="35"
                                    class="link-to-prism">src/weapp/weapp.service.ts:35</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                        <div class="io-description">
                            <b>Returns : </b>    <code>unknown</code>

                        </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getOpenId"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>getOpenId</b></span>
                        <a href="#getOpenId"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>getOpenId(code: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="93"
                                    class="link-to-prism">src/weapp/weapp.service.ts:93</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Default value</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>code</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>

                                            <td>
                                                    <code>&#x27;&#x27;</code>
                                            </td>

                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>unknown</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getOpenIdByWx"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>getOpenIdByWx</b></span>
                        <a href="#getOpenIdByWx"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>getOpenIdByWx(code: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>, body: <a href="../classes/IGetOpenIdFromWx.html" target="_self">IGetOpenIdFromWx</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="113"
                                    class="link-to-prism">src/weapp/weapp.service.ts:113</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Default value</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>code</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>

                                            <td>
                                                    <code>&#x27;&#x27;</code>
                                            </td>

                                        </tr>
                                        <tr>
                                                <td>body</td>
                                            <td>
                                                            <code><a href="../classes/IGetOpenIdFromWx.html" target="_self" >IGetOpenIdFromWx</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>

                                            <td>
                                                    <code>{}</code>
                                            </td>

                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>unknown</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getOpenIdFromDb"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>getOpenIdFromDb</b></span>
                        <a href="#getOpenIdFromDb"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>getOpenIdFromDb(phoneNumber: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="146"
                                    class="link-to-prism">src/weapp/weapp.service.ts:146</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Default value</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>phoneNumber</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>

                                            <td>
                                                    <code>&#x27;&#x27;</code>
                                            </td>

                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>unknown</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getPhoneNumber"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>getPhoneNumber</b></span>
                        <a href="#getPhoneNumber"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>getPhoneNumber(code: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="57"
                                    class="link-to-prism">src/weapp/weapp.service.ts:57</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Default value</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>code</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>

                                            <td>
                                                    <code>&#x27;&#x27;</code>
                                            </td>

                                            <td>
                                                    <p>手机号获取凭证</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>unknown</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getPhoneNumberByCrypto"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>getPhoneNumberByCrypto</b></span>
                        <a href="#getPhoneNumberByCrypto"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>getPhoneNumberByCrypto(code: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="79"
                                    class="link-to-prism">src/weapp/weapp.service.ts:79</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Default value</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>code</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>

                                            <td>
                                                    <code>&#x27;&#x27;</code>
                                            </td>

                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>        <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="removeWxInfo"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>removeWxInfo</b></span>
                        <a href="#removeWxInfo"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>removeWxInfo(id: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="175"
                                    class="link-to-prism">src/weapp/weapp.service.ts:175</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>id</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>unknown</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="sendMessage"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>sendMessage</b></span>
                        <a href="#sendMessage"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>sendMessage()</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="183"
                                    class="link-to-prism">src/weapp/weapp.service.ts:183</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                        <div class="io-description">
                            <b>Returns : </b>    <code>unknown</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="updateWxInfo"></a>
                    <span class="name">
                            <span class="modifier">Async</span>
                        <span ><b>updateWxInfo</b></span>
                        <a href="#updateWxInfo"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>updateWxInfo(id: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>, updateWeappDto: <a href="../classes/UpdateWeappDto.html" target="_self">UpdateWeappDto</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="171"
                                    class="link-to-prism">src/weapp/weapp.service.ts:171</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>id</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                        </tr>
                                        <tr>
                                                <td>updateWeappDto</td>
                                            <td>
                                                            <code><a href="../classes/UpdateWeappDto.html" target="_self" >UpdateWeappDto</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>unknown</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
</section>
            <section data-compodoc="block-properties">
    
    <h3 id="inputs">
        Properties
    </h3>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="configService"></a>
                    <span class="name">
                            <span class="modifier"></span>
                            <span class="modifier">Private</span>
                        <span ><b>configService</b></span>
                        <a href="#configService"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Type : </i>    <code>ConfigService</code>

                    </td>
                </tr>
                <tr>
                    <td class="col-md-4">
                        <b>Decorators : </b>
                        <br />
                        <code>
                            @Inject(ConfigService)<br />
                        </code>
                    </td>
                </tr>
                    <tr>
                        <td class="col-md-4">
                                <div class="io-line">Defined in <a href="" data-line="32" class="link-to-prism">src/weapp/weapp.service.ts:32</a></div>
                        </td>
                    </tr>


        </tbody>
    </table>
</section>

    </div>


    <div class="tab-pane fade  tab-source-code" id="source">
        <pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable, Inject } from &#x27;@nestjs/common&#x27;;
import { ReturnModelType } from &#x27;@typegoose/typegoose&#x27;;
import axios from &#x27;axios&#x27;;
import { InjectModel } from &#x27;nestjs-typegoose&#x27;;
import { CreateWeappDto } from &#x27;./dto/create-weapp.dto&#x27;;
import {
  QueryAccessTokenDto,
  QueryOpenIdByWxDto,
} from &#x27;./dto/query-access-token.dto&#x27;;
import { UpdateWeappDto } from &#x27;./dto/update-weapp.dto&#x27;;
import { Weapp as WeappSchema } from &#x27;./entities/weapp.entity&#x27;;
import { ConfigService } from &#x27;@nestjs/config&#x27;;
import { IGetOpenIdFromWx } from &#x27;./dto/query-openid.dto&#x27;;
import { log } from &#x27;console&#x27;;
import { SendMessageDto } from &#x27;./dto/send-message&#x27;;

@Injectable()
export class WeappService {
  constructor(
    @InjectModel(WeappSchema)
    private readonly weappModel: ReturnModelType&lt;typeof WeappSchema&gt;,
  ) {}
  @Inject(ConfigService)
  private configService: ConfigService;

  // TODO: 持久化 token
  async getAccessToken() {
    const queryAccessTokenDto: QueryAccessTokenDto &#x3D; {
      grant_type: &#x27;client_credential&#x27;,
      appid: this.configService.get(&#x27;we_app.appid&#x27;),
      secret: this.configService.get(&#x27;we_app.secret&#x27;),
    };

    const res &#x3D; await axios.get(&#x60;https://api.weixin.qq.com/cgi-bin/token&#x60;, {
      params: {
        ...queryAccessTokenDto,
      },
    });
    console.log(&#x27;getAccessToken res.data&#x27;, res.data);
    return res?.data ?? {};
  }

  /**
   * @description: 获取手机号
   * @param {*} access_token 接口调用凭证
   * @param {*} code 手机号获取凭证
   * @return {*}
   */
  async getPhoneNumber(code &#x3D; &#x27;&#x27;) {
    const getTokenRes &#x3D; await this.getAccessToken();
    const { access_token } &#x3D; getTokenRes;
    if (access_token) {
      console.log(&#x27;getPhoneNumber code&#x27;, code);
      console.log(&#x27;getPhoneNumber access_token&#x27;, access_token);
      const res &#x3D; await axios.post(
        &#x60;https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token&#x3D;${access_token}&#x60;,
        {
          code,
        },
      );
      console.log(&#x27;getPhoneNumber res.data&#x27;, res.data);
      return res?.data ?? {};
    }
    return getTokenRes;
  }

  /**
   * @description: 获取 openId
   * @return {*}
   */
  async getPhoneNumberByCrypto(code &#x3D; &#x27;&#x27;) {
    const { status, content } &#x3D; await this.getOpenIdByWx(code);
    if (status) {
      const { openid, session_key } &#x3D; content;
      // todo
    } else {
      return;
    }
  }

  /**
   * @description: 获取 openId
   * @return {*}
   */
  async getOpenId(code &#x3D; &#x27;&#x27;) {
    const wxRes &#x3D; await this.getOpenIdByWx(code);
    return wxRes;
    // 先从数据表中查询如果没有则去微信获取
    const dbRes &#x3D; await this.getOpenIdFromDb();
    if (!dbRes.id) {
      const wxRes &#x3D; await this.getOpenIdByWx(code);
      return wxRes;
    }
    return dbRes;
  }

  async findAll() {
    return await this.weappModel.find();
  }

  /**
   * @description: 获取 openId
   * @return {*}
   */
  async getOpenIdByWx(code &#x3D; &#x27;&#x27;, body: IGetOpenIdFromWx &#x3D; {}) {
    const queryAccessTokenDto: QueryOpenIdByWxDto &#x3D; {
      grant_type: &#x27;authorization_code&#x27;,
      appid: this.configService.get(&#x27;we_app.appid&#x27;),
      secret: this.configService.get(&#x27;we_app.secret&#x27;),
      js_code: code,
    };

    const res &#x3D; await axios.get(
      &#x60;https://api.weixin.qq.com/sns/jscode2session&#x60;,
      {
        params: {
          ...queryAccessTokenDto,
        },
      },
    );
    if (res?.data?.openId) {
      if (body.phone) {
        // 需要保存入库
        const { openId } &#x3D; res?.data ?? {};
        return await this.createWxInfo({
          openId,
          phoneNumber: body.phone,
        });
      }
    }
    return res?.data ?? {};
  }

  /**
   * @description: 根据手机号 从数据库 获取 openId
   * @return {*}
   */
  async getOpenIdFromDb(phoneNumber &#x3D; &#x27;&#x27;) {
    return await this.weappModel.findOne({ phoneNumber });
  }

  /**
   * @description: 创建 phone/openId 表
   * @param {CreateBannerDto} createDto
   * @return {*}
   */
  async createWxInfo(createDto: CreateWeappDto) {
    const { phoneNumber, openId } &#x3D; createDto;
    // 先查询是否存在该记录
    const findRes &#x3D; await this.weappModel.findOne({ phoneNumber, openId });
    if (findRes?._id) {
      // 存在
      return findRes;
    }
    // 是否需要删除 已有的 ？
    await this.weappModel.deleteMany({
      phoneNumber: phoneNumber,
    });
    const res &#x3D; await this.weappModel.create(createDto);
    return res;
  }

  async updateWxInfo(id: string, updateWeappDto: UpdateWeappDto) {
    return await this.weappModel.findByIdAndUpdate(id, updateWeappDto);
  }

  async removeWxInfo(id: string) {
    return await this.weappModel.findByIdAndRemove(id);
  }

  /**
   * @description: 发送订阅消息
   * @return {*}
   */
  async sendMessage() {
    const tokenRes &#x3D; await this.getAccessToken();
    console.log(&#x27;tokenRes&#x27;, tokenRes);
    if (!tokenRes?.access_token) {
      return tokenRes;
    }
    const sendMessageDto: SendMessageDto &#x3D; {
      template_id: this.configService.get(&#x27;we_app.template.id&#x27;),
      touser: &#x27;0d1jQFFa1lw4oG0lLRHa1rTVga0jQFFE&#x27;,
      page: &#x27;pages/job/job&#x27;, // 跳转到 任务页面
      data: {
        thing2: {
          value: &#x27;流程测试名称1&#x27;,
        },
        name7: {
          value: &#x27;name111&#x27;,
        },
        date3: {
          value: &#x27;2023-08-14&#x27;,
        },
        thing5: {
          value: &#x27;本级审核&#x27;,
        },
      },
      miniprogram_state: &#x27;developer&#x27;,
      lang: &#x27;zh_CN&#x27;,
    };
    const dto &#x3D; {
      template_id: &#x27;dglxA6jLzBFwu9YIsgTmSH8ZqxtZJpkxqzoQ8zuBNmg&#x27;,
      touser: &#x27;0d1jQFFa1lw4oG0lLRHa1rTVga0jQFFE&#x27;,
      page: &#x27;pages/job/job&#x27;,
      data: {
        thing2: {
          value: &#x27;流程测试名称1&#x27;,
        },
        name7: {
          value: &#x27;name111&#x27;,
        },
        date3: {
          value: &#x27;2023-08-14&#x27;,
        },
        thing5: {
          value: &#x27;本级审核&#x27;,
        },
      },
      miniprogram_state: &#x27;developer&#x27;,
      lang: &#x27;zh_CN&#x27;,
    };
    const token &#x3D;
      &#x27;74_TyYkAttusrVZYmI6J6yheUCpHN2q8zw-Bmh4zBVf7l2yEDsw-RsVa96JAznUKbdCfYwX9ePUpYaugwfnxoeoCRlkQ_6zb7XKyG1phPkYooI40v8lnSQsR4gsAbMGELdAIAPNU&#x27;;
    const str &#x3D; JSON.stringify(sendMessageDto);
    console.log(&#x27;sendMessage dto&#x27;, sendMessageDto);

    const res &#x3D; await axios.post(
      &#x60;https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token&#x3D;${tokenRes.access_token}&#x60;,
      // &#x60;https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token&#x3D;${token}&#x60;,
      sendMessageDto,
      { headers: { &#x27;Content-Type&#x27;: &#x27;application/json&#x27; } },
    );
    console.log(&#x27;sendMessage res&#x27;, res?.data);
    return res?.data ?? {};
  }
}
</code></pre>
    </div>

</div>













                   </div><div class="search-results">
    <div class="has-results">
        <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
        <ul class="search-results-list"></ul>
    </div>
    <div class="no-results">
        <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
    </div>
</div>
</div>
               <!-- END CONTENT -->
           </div>
       </div>

          <label class="dark-mode-switch">
               <input type="checkbox">
               <span class="slider">
                    <svg class="slider-icon" viewBox="0 0 24 24" fill="none" height="20" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" width="20" xmlns="http://www.w3.org/2000/svg">
                    <path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"></path>
                    </svg>
               </span>
          </label>

       <script>
            var COMPODOC_CURRENT_PAGE_DEPTH = 1;
            var COMPODOC_CURRENT_PAGE_CONTEXT = 'injectable';
            var COMPODOC_CURRENT_PAGE_URL = 'WeappService.html';
            var MAX_SEARCH_RESULTS = 15;
       </script>

       <script src="../js/libs/custom-elements.min.js"></script>
       <script src="../js/libs/lit-html.js"></script>

       <script src="../js/menu-wc.js" defer></script>
       <script nomodule src="../js/menu-wc_es5.js" defer></script>

       <script src="../js/libs/bootstrap-native.js"></script>

       <script src="../js/libs/es6-shim.min.js"></script>
       <script src="../js/libs/EventDispatcher.js"></script>
       <script src="../js/libs/promise.min.js"></script>
       <script src="../js/libs/zepto.min.js"></script>

       <script src="../js/compodoc.js"></script>

       <script src="../js/tabs.js"></script>
       <script src="../js/menu.js"></script>
       <script src="../js/libs/clipboard.min.js"></script>
       <script src="../js/libs/prism.js"></script>
       <script src="../js/sourceCode.js"></script>
          <script src="../js/search/search.js"></script>
          <script src="../js/search/lunr.min.js"></script>
          <script src="../js/search/search-lunr.js"></script>
          <script src="../js/search/search_index.js"></script>
       <script src="../js/lazy-load-graphs.js"></script>


    </body>
</html>
